package com.josework.springhelloworld;

import com.josework.springhelloworld.model.Article;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: Joseph Xu
 * @Date: 2021/7/10 22:25
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResponse {
    private boolean isok;
    private int code;
    private String message;
    private Object data;

    public static AjaxResponse success(){
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setCode(200);
        ajaxResponse.setIsok(true);
        ajaxResponse.setMessage("Response OK!");
        return ajaxResponse;
    }
    public static AjaxResponse success(Object object,String message){
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setCode(200);
        ajaxResponse.setIsok(true);
        ajaxResponse.setMessage(message);
        ajaxResponse.setData(object);
        return ajaxResponse;
    }
}
